# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgbase=aom
pkgname=(
  aom
  aom-docs
)
pkgver=3.7.1
pkgrel=1
pkgdesc="Alliance for Open Media video codec"
url="https://aomedia.org/"
arch=(loong64 x86_64)
license=(
  BSD
  custom:PATENTS
)
depends=(
  gcc-libs
)
makedepends=(
  cmake
  doxygen
  ninja
  yasm
)
source=(
  https://storage.googleapis.com/aom-releases/libaom-$pkgver.tar.gz{,.asc}
)
b2sums=('a5bc8aaa538353fa405520fc096459d0009348c590dc585377e53971df252bac0b5bea40b6483c8be54caa7a0e8fccd761c5b3ec0db4144becec3cc12a91a5e9'
        'SKIP')
validpgpkeys=(
  B002F08B74A148DAA01F7123A48E86DB0B830498 # AOMedia release signing key <av1-discuss@aomedia.org>
)

prepare() {
  cd libaom-$pkgver
}

build() {
  local cmake_options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=None
    -DBUILD_SHARED_LIBS=1
    -DENABLE_TESTS=0
  )

  # Upstream would like -O3
  CFLAGS="${CFLAGS/-O2/-O3}"
  CXXFLAGS="${CXXFLAGS/-O2/-O3}"

  cmake -S libaom-$pkgver -B build -G Ninja "${cmake_options[@]}"
  cmake --build build
}

package_aom() {
  provides=(libaom.so)

  DESTDIR="$pkgdir" cmake --install build

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 libaom-$pkgver/{LICENSE,PATENTS}
}

package_aom-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mkdir -p "$pkgdir/usr/share/doc"
  cp -r build/docs/html "$pkgdir/usr/share/doc/$pkgbase"

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 libaom-$pkgver/{LICENSE,PATENTS}
}

# vim:set sw=2 sts=-1 et:
